<%@ page import="com.chg.mymvc.entity.News" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/7/13
  Time: 19:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link href="css/main.css" rel="stylesheet">
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<div class="AccountManagement_c " id="AccountManagement_c">
    <h3>新闻管理
        <div class="amcl fr">
            <form action="selectnews" method="post" id="formform">
                <input type="text" placeholder="标题" class="fl" name="getlistbyname" id="getlistbyname">

                <div class="search fl">   <img id="imgimg" src="<%=request.getContextPath()%>/images/search.png"  onclick="imgclick()"/></div>
            </form>
        </div>
    </h3>
    <div class="AM_ct text_center">
        <form action="news.html" method="post">
        <div class="AM_ct_in">
       <button class="add_btn df_btn fl"  type="submit">发布</button>

            <div class="fr df_btn ac_btn" id="ac_Account_btn">账号授权</div>
        </div>
        </form>
    </div>

    <div class="list">
        <ul class="list_h">
            <li class="b20"><label><input type="checkbox" name=""><span>栏目</span></label></li>
            <li class="b20"><label><input type="checkbox" name=""><span>标题</span></label></li>
            <li class="b20"><label>内容</label></li>
            <li class="b20"><label>创建时间</label></li>
        </ul>
        <div class="list_b_c">

            <%
                List<News> list = (List<News>) request.getAttribute("ilist");
                if(list.size()<1){
            %>
            <ul class="list_null">
                <li class="text_center">未添加管理员账户！</li>
            </ul>
            <%  }  else{%>

            <%
                for(News news:list){
            %>
            <ul class="list_b" style="width:100%">
                <li style="width:10%"><label><span><%=news.getPerm()%></span></label></li>
                <li style="width:10%"><label><span><%=news.getTitle()%></span></label></li>
                <li style="width:25%"><label><%=news.getContent()%></label></li>
                <li style="width:10%"><label><%=news.getCrtime()%></label></li>
                <li style="text-align: center;width:45%">
                    <div>
<%--                        <button class="edit_btn df_btn fl edit_Account_btn" id="edit_Account_btn"--%>
<%--                                onclick="updateFuction(<%=news.getId()%>,'<%=news.getTitle()%>','<%=news.getContent()%>')">--%>
<%--                            编辑--%>
<%--                        </button>--%>
                        <button  class="df_btn fl" onclick="detail(<%=news.getId()%> )" >查看详情</button>
                        <button  class="delete_btn df_btn fl" onclick="abc(<%=news.getId()%>)">删除</button>


                    </div>
                </li>
            </ul>
            <%  }}%>



        </div>
        <%--//页数不能是静态的，得是遍历出来的--%>

        <div class="pull_page">
          <a href="nmanage.html?pagenum=${page.prePage}">  <div class="fl pull_page_up">上一页</div></a>

            <ul>
                <c:forEach begin="1" end="${page.pages}" var="pag">

                    <c:choose>
                        <c:when test="${page.pageNum == pag}">
                           <a href="nmanage.html?pagenum=${pag}"> <li class="on">${pag}</li></a>
                        </c:when>
                        <c:otherwise>
                          <a href="nmanage.html?pagenum=${pag}">  <li >${pag}</li></a>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
            </ul>
           <a href="nmanage.html?pagenum=${page.nextPage}"> <div class="fl pull_page_down">下一页</div></a>
        </div>


    </div>
</div>


<!-- 弹窗 -->
<!-- 添加账户 -->
<div class="add_Account dn">
    <form action="" method="post" id="user_detail_form">

        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    详情
                    <span class="fr add_Account_close"><img src="images/close.png"></span>
                </div>
            </div>
<%--            <span id="usermsg" style="color: red"></span>--%>
<%--            <div class="user_name user_i">--%>
<%--                <label>用户名</label> <input type="text" placeholder="输入用户名" name="name" id="add_user_ajax" onblur="checkname()"/>--%>
<%--            </div>--%>
<%--            <div class="user_password user_i">--%>
<%--                <label>密<i>调</i>码</label> <input type="password" placeholder="输入密码" name="password">--%>
<%--            </div>--%>
            <label>lanmu</label>
            <textarea class="release_news_content" rows="50" cols="60" id="richtext" placeholder="编辑正文" name="content"></textarea>
            <input type="submit" class="add_Account_ok_btn text_center"  style="margin-left:35px;margin-top:-5px;" ></input>
        </div>
    </form>
</div>

<!-- 账户编辑 -->
<div class="add_Account dn" id="user_column">
    <form action="updateuser" method="post" >
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    编辑账户
                    <span class="fr add_Account_close"><img src="images/close.png"></span>
                </div>
            </div>
            <div class="column_now ">正在编辑 <span id="spanspan"></span>账户</div>

            <input type="text" name="updateNewId" id="updateNewId" style="display: none">

            <div class="user_name user_i">
                <label>用户名</label>
                <input type="text" placeholder="输入用户名" name="updatename" id="updatename">
            </div>
            <div class="user_password user_i">
                <label>密<i>调</i>码</label>
                <input type="password" placeholder="输入密码" name="updatepassword"  id="updatepassword">
            </div>
            <%--        <%--%>
            <%--            request.setAttribute("uname",);--%>
            <%--            request.setAttribute("upassword",);--%>
            <%--        %>--%>
            <input type="submit" class="add_Account_ok_btn text_center" style="margin-left:35px;margin-top:-5px;" ></input>
        </div>
    </form>
</div>

<!-- 删除账户 -->
<div class="add_Account dn" id="delete_Account">
    <form action="deleteuser" method="post" id="user_delete_form">
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    删除账户
                    <span class="fr add_Account_close"><img src="images/close.png"></span>
                </div>
            </div>
            <div class="delete_text">确定删除“ <span>jiaopwuchu</span> ”账户吗？</div>
            <input type="submit" class="add_Account_ok_btn text_center" id="delete_Account_ok_btn">确<i>皮</i>定</input>
        </div>
    </form>
    <div>



        <!-- 账户授权 -->
        <div class="add_Account dn" id="ac_Account">
            <div class="add_Account_c">
                <div class="add_Account_h">
                    <div class="add_Account_h_in">
                        账户栏目授权
                        <span class="fr add_Account_close"><img src="images/close.png"></span>
                    </div>
                </div>
                <ul>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                    <li><label><input type="checkbox" name="">&nbsp;<span>教务处</span></label></li>
                </ul>
                <div class="add_Account_ok_btn text_center" id="ac_Account_ok_btn">保<i>呀</i>存</div>
            </div>
        </div>
        <script>
            var updateFuction;   //定义一全局变量
            updateFuction=function update(id,name,password) {
                if (id != null) {
                    $("#updateNewId").val(id);
                    $("#updatename").val(name);
                    $("#updatepassword").val(password);
                    $(".add_Account #spanspan").val(name)

                }
            }

            function  abc(str) {
                if(confirm("确认删除吗")){
                    window.location.href="deletenews?id="+str;
                }else {
                    return false;
                }

            };

            function  detail(str) {

                    window.location.href="detailnews?id="+str;


            };


            function checkname() {
                var name=$("#add_user_ajax").val();
                $.ajax({
                    type: "GET",
                    url: "adduserajax?addname="+name,
                    dataType: "text",
                    success : function(data){

                        $("#usermsg").html(data);

                    }
                });
            }


            $("#imgimg").on('click',function(){
                $("#formform").submit();
            })
            // function add_user_ajax(){
            //     var name = document.getElementById("add_user_ajax").value;
            //     // 使用谁来请求XMLHttpRequest对象     请求路径    请求的类型      携带的参数     什么时候成功  响应的内容
            //     var req=new XMLHttpRequest();
            //     req.open("post","adduser")//打开一个请求
            //     req.send();//发送请求
            //     //等待响应
            //     //响应对应五个状态码，每当readyState属性改变时，就会调用该函数      4？？？
            //     req.onreadystatechange=function(){
            //         //获取服务的响应信息     服务器响应就绪   状态码正常
            //
            //         if (req.readyState==4 && req.status==200)
            //         {
            //             var msg = document.getElementById("msg");
            //             if(req.responseText=="ok"){
            //                 msg.innerHTML="<font color='red'>用户名已经存在</font>";
            //             }
            //             else{
            //                 msg.innerHTML="<font color='#7fffd4'>√<font>";
            //             }
            //         }
            //     }
            // }


        </script>
</body>
</html>
